using System;
using BookingSystem.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BookingSystem.Mappings
{
    [TestClass]
    public class BookingMapTests
    {
        
        [TestMethod]
        public void NewBooking()
        {
            using (var session = Config.CreateSessionFactory().OpenSession())
            {
                var booking = new Booking();
                session.SaveOrUpdate(booking);
                var saved = session.CreateCriteria(typeof(Booking)).List<Booking>();

                Assert.AreEqual(saved[0].Id, 1);
            }
        }

        [TestMethod]
        public void NewBooking_StartDate()
        {
            using (var session = Config.CreateSessionFactory().OpenSession())
            {
                var booking = new Booking();
                booking.StartDate = DateTime.Today;
                session.SaveOrUpdate(booking);
                var saved = session.CreateCriteria(typeof(Booking)).List<Booking>();

                Assert.AreEqual(saved[0].StartDate, DateTime.Today);
            }
        }
        
        [TestMethod]
        public void NewBooking_EndDate()
        {
            using (var session = Config.CreateSessionFactory().OpenSession())
            {
                var booking = new Booking();
                booking.EndDate = DateTime.Today;
                session.SaveOrUpdate(booking);
                var saved = session.CreateCriteria(typeof(Booking)).List<Booking>();

                Assert.AreEqual(saved[0].EndDate, DateTime.Today);
            }
        }


    }

}